<?php
class DataConnection {
	private static $instance;
	private function __construct() {
	}
	private function __destruct() {
		self::$instance->close();
		unset( self::$instance );
	}
	public static function getConnection() {
		/*
		if( !isset( self::$instance ) ) {
			@ self::$instance = new mysqli( 'localhost', 'root', '9912abcd', 'mofachi' );
			if( mysqli_connect_errno() ) {
				echo 'cannot connect to mysql server';
				return null;
			}
		}
		return self::$instance;
		*/
		$connection = new mysqli( 'localhost', 'root', '9912abcd', 'mofachi' );
		$connection->set_charset( "utf8" );
		return $connection;
	}
	public static function closeConnection() {
		self::$instance->close();
		unset( self::$instance );
	}
	public function __clone() {
		trigger_error( 'Cannot be cloned.', E_USER_ERROR );
	}
}
?>